import { ref, watch, Ref } from 'vue'
/**
 * @description 切换页面标题
 * @author jinzz
 * @returns title { String } 页面标题
 * @returns setTitle { ( val: String ) => {} } 设置页面标题
 */
const useTitle = () => {
  let title: Ref<string> = ref(document.title)

  watch(title, (val) => {
    document.title = val
  })

  const setTitle: Function = (val: string) => {
    title.value = val
  }

  return {
    title,
    setTitle
  }
}
export default useTitle